<template>
<div class="wrapper">
  <div class="seakInfo">
    <div class="info-title">选择专家</div>
    <div class="seak-txt">{{routerParems.name}}，{{ routerParems.sex == 1 ? '女' : '男' }}，{{ routerParems.age }}岁，2024年2月13日，{{ routerParems.illness_info }}</div>
  </div>
  <div class="content">
    <div class="info-title">选择专家</div>
    <div class="panel" v-for="(item,idx) in listData" :key="item.id" @click="currentIndex = idx">
      <img class="info-avatar" :src='item.head_img' />
      <div class="introduce">
        <div class="title">{{ item.nickname }} {{ item.hospital_name }} 胸外科</div>
        <div class="desc">{{ item.self_info }}</div>
        <div class="checkbox" :class="{currentCls:currentIndex == idx}"></div>
      </div>
    </div>
    <div class="meet-time">
      <div class="info-title">选择会诊时间</div>
      <div class="picker-date">
        <picker mode='date' class="date" :value="date" @change="bindCheckinDateChange">
          <div class='picker'>
            {{ date }}
          </div>
        </picker>
        <picker mode='time' class="date" :value="time" @change="bindCheckinTimeChange">
          <div class='picker'>
            {{ time }}
          </div>
        </picker>
      </div>

    </div>
  </div>
  <div>
  <div class="option">
    <!-- <button class='add-sick' type='primary'>咨询AI</button> -->
    <button class='next' type='primary'  @click="ev_invite">向专家发送邀请</button>
    <!-- toPage('/pages/meeting/index') -->
  </div>
    <!-- <button class='btn-max-w' type='primary' @click="toPage('/pages/meeting/index')">向专家发送邀请</button> -->
  </div>

</div>
</template>

<script>
	import request from '../../utils/request'

export default {
  components:{
  },
  data() {
    return {
      currentIndex:-1,
      routerParems:{},
      listData:[],
      case_id:'',
      expert_ids:'',
      meeting_at:'',
      date:'选择日期',
      time:'选择时间'
    }
  },
  async onLoad(option) {
    this.routerParems = JSON.parse(option.data)
    console.log("🚀 ~ onLoad ~ this.routerParems:", this.routerParems)

    this.ev_search()
  },
  methods: {
    bindCheckinDateChange(e){
      this.date = e.detail.value
    },
    bindCheckinTimeChange(e){
      this.time = e.detail.value
    },
    async ev_invite(){
      // uni.showToast({
      //   title: '邀请成功',
      //   icon: 'success',
      //   mask: true
      // })
      // return
      console.log("🚀 ~ ev_invite ~ this.currentIndex:", this.currentIndex)
      console.log("🚀 ~ ev_invite ~ this.listData:", this.listData)
      const expert_ids = this.listData[this.currentIndex].id

      const parames = {
        
        case_id:this.routerParems.id,
        expert_ids,
        meeting_at:`${this.date} ${this.time}`
      }
      await request('api/meeting/meetingAdd', 'post', parames);
      uni.showToast({
        title: '发送成功',
        icon: 'success',
        mask: true
      })
      this.toPage('/pages/meeting/index')
    },
    async ev_search(){
      const parames = {
        keywords:this.keywords
      }
      const resData = await request('api/meeting/expertList', 'post', parames);
      console.log("🚀 ~ ev_search ~ resData:", resData)
      this.listData = resData.data
    },
    toPage(url){
        uni.navigateTo({
          url: url
        });
    }
  }
}
</script>

<style lang="scss" scoped>


.wrapper {
  display       : flex;
  flex-direction: column;
  background-color: #fff;
  border-radius: 15upx;
  padding-bottom: 50upx;
  .info-title  {
    font-size: 32upx;
    color: hsl(0, 0%, 0%);
    position: relative;
    padding-left: 20upx;
    &::before{
      content: '';
      position: absolute;
      width: 8upx;
      height: 30upx;
      background-color: #0094FF;
      border-radius: 4upx;
      left: 0;
      top: 8upx;
    }
  }
  .search {
    border-bottom: 1upx solid #E9E9E9;
    padding: 40upx 0;
    margin: 0 10upx;
    display: flex;
    align-items: center;
    .search-input {
      width: 540upx;
      color: #0e0e0e;
      border: 1upx solid #66C2FF;
      display: block;
      height: 80upx;
      background-color: #F0F9FF;
      border-radius: 40upx;
      padding-left: 40upx;
      margin-top: 15upx;
      color: #000000;
    }
    .searchText {
      color: #0094FF;
      margin:10upx 0 0 30upx;
    }
  }
  .seakInfo {
    background: #F0F9FF;
    border-radius: 20upx 20upx 20upx 20upx;
    border: 1upx solid #66C2FF;
    margin: 20upx 40upx;
    padding: 30upx 20upx;
    font-size: 28upx;
    .seak-txt {
      margin-top: 20upx;
    }
  }
  .content {
    background: #FFFFFF;
    box-shadow: 0upx -8upx 40upx 0upx rgba(0,73,126,0.1);
    border-radius: 60upx 60upx 0upx 0upx;
    padding: 30upx 40upx;
    margin-top: 10upx;
    
    .info-avatar {
      display: block;
      width  : 120upx;
      height : 120upx;
      margin-top: 20upx;
      border-radius: 50%;
    }
    .panel {
      border-bottom: 1upx solid #E9E9E9;
      position: relative;
      padding: 30upx 0;
      font-size: 30upx;
      display: flex;
      align-items: center;
      .introduce {
        padding: 0 0 0 20upx;
        width: 70%;
      }
      .desc {
        font-size: 24upx;
        margin-top: 10upx;
      }
      .checkbox {
        width: 32upx;
        height: 32upx;
        background: #D9F0FF;
        border: 1upx solid #0094FF;
        position: absolute;
        top: calc(50% - 16upx);
        right: 0;
        border-radius: 15upx;
      }
      .currentCls {
        background: url(@/static/images/check-icon.png) center center no-repeat;
        background-size: cover;
      }
    }
    .meet-time {
      margin-top: 40upx;
    }
    .picker-date {
      display: flex;
      justify-content: space-between;
      margin-top: 30upx;
      .date {
        width: 320upx;
        height: 80upx;
        background: #F0F9FF;
        border-radius: 60upx 60upx 60upx 60upx;
        border: 1upx solid #66C2FF;
        color: #BDBDBD;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
  }
  .btn-max-w {
    background-color: #0094FF;
    border-radius: 130upx;
    width: 600upx;
    margin-top: 80upx;
    color:#fff;
  }
  .option {
    display: flex;
    position: fixed;
    bottom: 100upx;
    left: 0;
    right: 0;
    .add-sick {
      width: 230upx;
      height: 88upx;
      background: #E3F3FF;
      border-radius: 100upx;
      color: #0094FF;
    }
    .next {
      background-color: #0094FF;
      border-radius: 130upx;
      width: 405upx;
      color: #fff;
    }
  }
}




</style>
